Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(profiler): no such file /proc/{pid}/task #117

Merged
merged 13 commits into from
Jul 12, 2023
Merged

fix(profiler): no such file /proc/{pid}/task #117

merged 13 commits into from
Jul 12, 2023

Conversation

Almouro
Copy link
Member

@Almouro Almouro commented Jun 5, 2023

Tested with APKPure apk and this command:

node packages/e2e-performance/dist/bin.js test --bundleId com.apkpure.aegon --testCommand "maestro test test.yaml --no-ansi" --iterationCount 1 --duration 5000 --record

test.yaml is

appId: com.apkpure.aegon
---
- launchApp
- assertVisible: .*.*

With current flashlight test command it used to show an error "no such file /proc/{pid}/task" in CLI and then actual measures of the app opened were lost

What was happening was:

  • app was actually opened in the background when running flashlight test
  • running maestro restarted the app with a new pid
  • C++ profiling crashed, only measures from when the app was in the background were kept

Now:

  • new pid change is detected from C++
  • we restart measures with this new pid
  • on JS side we ignore previous measures

@netlify
Copy link

netlify bot commented Jun 5, 2023

Deploy Preview for flashlight-docs canceled.

Name Link
🔨 Latest commit 6ac2118
🔍 Latest deploy log https://app.netlify.com/sites/flashlight-docs/deploys/64ae9bb3cd720c00080ebda2

@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@Almouro Almouro force-pushed the fix/no-such-file branch 2 times, most recently from 4085dcd to dae63fa Compare July 6, 2023 10:31
@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@Almouro Almouro changed the title fix(profiler): no such file /proc/{pid}/task (WIP) fix(profiler): no such file /proc/{pid}/task Jul 7, 2023
@Almouro Almouro marked this pull request as ready for review July 7, 2023 07:36
@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@@ -10,7 +12,7 @@ const mockSpawn = (): { stdout: EventEmitter; kill: () => void } => {
.spyOn(require("child_process"), "spawn")
.mockImplementationOnce((...args) => {
expect(args).toEqual(["adb", ["shell", "atrace", "-c", "view", "-t", "999"]]);
return mockProcess;
return mockProcess as ChildProcess;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we okay with these casts I suppose ?

@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
Copy link
Contributor

@legkikh legkikh Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes (but at least it's in a test file)

.spyOn(require("child_process"), "spawn")
.mockImplementationOnce((...args) => {
expect(args).toEqual(["adb", ["shell", "atrace", "-c", "view", "-t", "999"]]);
return aTraceMock as ChildProcess;
return aTraceMock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well i was wondering why the extra cast on the previous commit haha

process.stderr?.on("data", (data) => {
const log = data.toString();

// Ignore errors, it might be that the thread is dead and we can read stats anymore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't ?

@flashlight-bot
Copy link
Contributor

Flashlight Automated Report 🔦

@Almouro Almouro merged commit 4f51759 into main Jul 12, 2023
5 checks passed
@Almouro Almouro deleted the fix/no-such-file branch July 12, 2023 12:42
Almouro added a commit that referenced this pull request Jul 12, 2023
* fix(profiler): ensure failure if profiling script fails

* docs(cpp): update docs to run c++ profiler

* refactor(cpp): move logic to function

* chore(cpp): throw custom error if directory not found

* refactor: move some test utils to e2e folder

* refactor(test): separate between atrace mock and profiler mock

* refactor(test): fix some typings

* refactor(profiler): add logStderr option

* refactor(profiler): pass errors on stderr instead of stdout

* fix(profiler): reset measures if pid changes

Pid can change if app is restarted in the background

* chore(cpp): recompile executables

* fix(profiler): ensure graceful kill doesn't throw error

* chore: fix comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants